/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Xuly;

import java.util.ArrayList;

import javax.xml.transform.TransformerException;
import org.w3c.dom.Document;

/**
 *
 * @author CULUN
 */
public class MyDatabase {

    private String name = "";
    private ArrayList<MyTable> tables = new ArrayList<MyTable>();

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public ArrayList<MyTable> getTables() {
        return tables;
    }

    public void setTables(ArrayList<MyTable> tables) {
        this.tables = tables;
    }

    public MyDatabase() {
    }
    
    public MyDatabase(String pathInFile) throws TransformerException { 
        ReadDatabaseFromFile(pathInFile);
    }

    public MyDatabase(String name, ArrayList<MyTable> tables) {
        this.name = name;
        this.tables = tables;
    }

    public void WriteDatabaseToFile(String pathFile) throws TransformerException {

        Document document = XMLProvider.CreateXML(this);
        XMLProvider.WriteToFile(document, pathFile);
    }
    
    public void ReadDatabaseFromFile(String pathFile) throws TransformerException {

        Document document = XMLProvider.ParseXMLFromFile(pathFile);
        MyDatabase temp = XMLProvider.CreateDatabase(document);
        this.tables = temp.getTables();
        this.name = temp.getName();
    }
}
